package com.leen.video.controller;

import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.Picture;
import com.leen.video.repository.PictureRepository;
import com.leen.video.service.PictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "Sm.Ms图床接口API")
@RequestMapping(value = "/video")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @ApiOperation(value = "全查询")
    @GetMapping(value = "/picture/findAll")
    public ResultVO<ResultVO> findAll(){
        return ResultVO.success(this.pictureService.findAll());
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "/picture/add")
    public ResultVO<String> add(@RequestBody Picture picture){
        Picture save =this.pictureService.save(picture);
        return save!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/picture/updata")
    public ResultVO<String> updata(@RequestBody Picture picture){
        Picture updata =this.pictureService.save(picture);
        return updata!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }
}



